package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


/**
 * 护理等级相关接口
 */
@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级相关接口")
public class NursingLevelController extends BaseController {

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult<List<NursingLevelVo>> showAllNursingLevel() {
        List<NursingLevelVo> nursingLevelVoList = nursingLevelService.showAllNursingLevel();
        return success(nursingLevelVoList);
    }

    @GetMapping("/listByPage")
    @ApiOperation("分页条件查询护理等级")
    public ResponseResult<PageResponse<NursingLevelVo>> queryPage(
            @ApiParam(value = "页码") @RequestParam(value = "pageName", defaultValue = "1") Integer pageName,
            @ApiParam(value = "每页大小") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @ApiParam(value = "护理等级名称") String name,
            @ApiParam(value = "护理等级状态") Integer status) {
        PageResponse<NursingLevelVo> nursingLevelVoPageResponse = nursingLevelService.queryPage(pageName, pageSize, name, status);
        return success(nursingLevelVoPageResponse);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult<NursingLevelVo> showNursingLevelById(@PathVariable("id") Integer id) {
        NursingLevelVo nursingLevelVo = nursingLevelService.showNursingLevelById(id);
        return success(nursingLevelVo);
    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return success();
    }

    @PutMapping("/update")
    @ApiOperation("修改护理等级")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.updateNursingLevel(nursingLevelDto);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("根据id删除护理等级")
    public ResponseResult deleteNursingLevelById(@PathVariable("id") Integer id) {
        nursingLevelService.deleteNursingLevelById(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用护理等级")
    public ResponseResult updateNursingLevelStatusById(@PathVariable("id") Integer id, @PathVariable("status") Integer status) {
        nursingLevelService.updateNursingLevelStatusById(id,status);
        return success();
    }
}
